/**
 * Created by xqing on 2017/12/5.
 */

;
(function(w, $) {
    function txActivity(opts) {
        console.log(this);
        var defaultOpts = {
            node: null
        };
        /**
         * 参数合并
         */
        this.opts = $.extend(defaultOpts, opts);
        /**
         * 请求URL
         * @type {{url1: string}}
         */

        this.url = {
            // 测试服host指向 192.168.60.113 xqtest.sctv.com

            //登陆
            // login:'http://xqtest.sctv.com:9080/api/transmitRequest/user/loginByToken',
            // login:'http://uistest.sctv.com:8080/api/transmitRequest/user/loginByToken',
            login: 'http://uisact.sctv.com:28080/api/transmitRequest/user/loginByToken',
            //可用次数查询
            // getCount:'http://xqtest.sctv.com:9080/api/lottery/award/availableCount',
            // getCount:'http://uistest.sctv.com:8080/api/lottery/award/availableCount',
            getCount: 'http://uisact.sctv.com:28080/api/lottery/award/availableCount',
            //抽奖
            // getLottery:'http://xqtest.sctv.com:9080/api/lottery/award/getLottery',
            // getLottery:'http://uistest.sctv.com:8080/api/lottery/award/getLottery',
            getLottery: 'http://uisact.sctv.com:28080/api/lottery/award/getLottery',
            //提交中奖信息
            // userApply:'http://xqtest.sctv.com:9080/api/lottery/award/apply',
            // userApply:'http://uistest.sctv.com:8080/api/lottery/award/apply',
            userApply: 'http://uisact.sctv.com:28080/api/lottery/award/apply',
            //氛围渲染的滚动中奖名单
            // listForShow:'http://xqtest.sctv.com:9080/api/lottery/award/getAllLotteryRecordsforShow',
            // listForShow:'http://uistest.sctv.com:8080/api/lottery/award/getAllLotteryRecordsforShow',
            listForShow: 'http://uisact.sctv.com:28080/api/lottery/award/getAllLotteryRecordsforShow',
            //查询我的中奖记录
            // myRecord:'http://xqtest.sctv.com:9080/api/lottery/award/getLotteryRecord'
            // myRecord:'http://uistest.sctv.com:8080/api/lottery/award/getLotteryRecord'
            myRecord: 'http://uisact.sctv.com:28080/api/lottery/award/getLotteryRecord'




        };
        /**
         * tag参数
         * @type {{pandaVideo: string, pandaWowtv: string, scfocus: string, iptvvote: string}}
         */
        this.platform = {
            pandaVideo: "392861C427FE30420D959D043CD32FFD",
            pandaWowtv: "A9A2320BDB0006D83963CCFF2FF7E3A0",
            scfocus: "FAF092CD57FCF2F335AA0BD2658E817B",
            iptvvote: "189670BE1410EE9DA7DDD7E9DDFEFF7A",
            pc: "41357B790F3A7A90B2A529BEEF629C43"
        };

        /**
         * 是否已登陆
         * @type {boolean}
         */
        this.login = true;
        /**
         * 是否使用mock数据
         * @type {boolean}
         */
        this.mock = true;
        /**
         * 用户token
         * @type {string}
         */
        this.token = '';
        this.uId = '';
        this.actId = '';
        this.mId = '';
        this.pId = '';
        this.jsonSource = $(this.opts.node).data('prize') + '';
        this.prizeJson = '';

        this.mockJson = {
            "data": [

                {
                    "prizeId": "1030",
                    "prizeName": "100元电影卡",
                    "prizeImg": "http://app.sctv.com/tv/XMSP_CJHD/HD_NKDY/lottery_main/CJY_CJSZ/201805/W020180509565356400323.png",
                    "prizeImg2": "http://app.sctv.com/tv/XMSP_CJHD/HD_NKDY/lottery_main/CJY_CJSZ/201805/W020180509565358439217.jpg",

                },

                {
                    "prizeId": "1036",
                    "prizeName": "500元电影卡",
                    "prizeImg": "http://app.sctv.com/tv/XMSP_CJHD/HD_NKDY/lottery_main/CJY_CJSZ/201805/W020180509565698822476.png",
                    "prizeImg2": "http://app.sctv.com/tv/XMSP_CJHD/HD_NKDY/lottery_main/CJY_CJSZ/201805/W020180509565700851968.jpg",

                },

                {
                    "prizeId": "1027",
                    "prizeName": "1000元电影卡",
                    "prizeImg": "http://app.sctv.com/tv/XMSP_CJHD/HD_NKDY/lottery_main/CJY_CJSZ/201805/W020180509566088040353.png",
                    "prizeImg2": "http://app.sctv.com/tv/XMSP_CJHD/HD_NKDY/lottery_main/CJY_CJSZ/201805/W020180509566089603767.jpg",

                },

                {
                    "prizeId": "1039",
                    "prizeName": "电影兑换券2张",
                    "prizeImg": "http://app.sctv.com/tv/XMSP_CJHD/HD_NKDY/lottery_main/CJY_CJSZ/201805/W020180509569971986495.png",
                    "prizeImg2": "http://app.sctv.com/tv/XMSP_CJHD/HD_NKDY/lottery_main/CJY_CJSZ/201805/W020180509569973387940.jpg",

                },

                {}
            ]
        };






        this._init();







    }
    $.extend(txActivity.prototype, {
        /**
         * 初始化入口
         * @private
         */
        _init: function() {
            var self = this;
            self._uaCheck();
            self._uiBind();
            self._getInfo();


        },
        /**
         * 检查ua，如果不在app内部则呼出蒙层
         * @private
         */
        _uaCheck: function() {
            var self = this;
            var windowHeight = window.innerHeight;
            var unAppPopup = $('body').find('#j-to-download');
            var ua = navigator.userAgent;
            //给高度赋值
            unAppPopup.css('height', windowHeight);
            unAppPopup.find(".img-area img").css('height', windowHeight);
            if ($(self.opts.node).hasClass('my-record')) {
                $('.my-record').css('min-height', windowHeight)
            }
            if ($(self.opts.node).hasClass('index')) {
                $('.index').css('min-height', windowHeight)
            }
            if ($(self.opts.node).hasClass('lottery-main')) {
                $('.xiaozunbao').css('min-height', windowHeight)
            }

            // alert(ua);
            if (ua.indexOf('pandavideo') > -1) {
                 unAppPopup.removeClass('hide');
            } else {
                // unAppPopup.removeClass('hide');
                // self._getShareInfo();

            }
        },
        /**
         * 从url中获取token，mid
         * 从dom中获取acid
         * @private
         */
        _getInfo: function() {
            var self = this,
                thisUrl = window.location.href;
            // urlParaString = window.location.href.split("?")[1],
            // paraArr = urlParaString.split("&"),
            // len = paraArr.length;
            // paraToken = null;
            // function getCookie(name) {
            //     var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
            //     if(arr=document.cookie.match(reg))
            //         return unescape(arr[2]);
            //     else
            //         return null;
            // }
            // //从url中获取token
            // if(thisUrl.indexOf('token') > -1){

            //     if (typeof(urlParaString)!='undefined'){
            //         //url中取token
            //         for (var i=0; i<len; i++) {
            //             // document.write(cars[i] + "<br>");
            //             if(typeof(paraArr[i].split("token=")[1])!= 'undefined'){
            //                 paraToken = paraArr[i].split("token=")[1];
            //             }
            //         }
            //     }

            //     self.token = paraToken;
            // }
            // //从url中获取mid
            // if(thisUrl.indexOf('mid') > -1){

            //     if (typeof(urlParaString)!='undefined'){
            //         //url中取token
            //         for (var j=0; j<len; j++) {
            //             // document.write(cars[i] + "<br>");
            //             if(typeof(paraArr[j].split("mid=")[1])!= 'undefined'){
            //                 paraMid = paraArr[j].split("mid=")[1];
            //             }
            //         }
            //     }

            //     self.mId = paraMid;
            // }
            // //从url中获取pid
            // if(thisUrl.indexOf('pid') > -1){

            //     if (typeof(urlParaString)!='undefined'){
            //         //url中取token
            //         for (var j=0; j<len; j++) {
            //             // document.write(cars[i] + "<br>");
            //             if(typeof(paraArr[j].split("pid=")[1])!= 'undefined'){
            //                 paraPid = paraArr[j].split("pid=")[1];
            //             }
            //         }
            //     }

            //     self.pId = paraPid;
            // }



            //从dom中获取actid
            //self.actId = $(self.opts.node).data('actid');

            //载入时判断是否需要获取当前可用次数
            if ($(self.opts.node).hasClass('lottery-main')) {
                self._getCountAjax();
                self._getListForShow();
            }

            //载入时判断是否需要请求中奖记录
            if ($(self.opts.node).hasClass('my-record')) {
                self._getMyRecord();
            }
            //载入时判断是否需要遍历奖品图片
            if ($(self.opts.node).hasClass('need-img')) {
                self._needImg();
            }

        },
        /**
         * 分享页
         * 区县名称，以及图片路径获取
         * @private
         */
        _getShareInfo: function() {
            console.log("等待接口获取分享的图片和路径");
        },
        /**
         * 交互事件绑定
         * @private
         */
        _uiBind: function() {
            var self = this;
            var wrapper = $(self.opts.node);

            //首页大按钮"立即抽奖"
            //点击判定登录状态
            wrapper.delegate('#j_check_login', 'click', function() {
                self._loginCheck();
            });

            //查看我的中奖记录
            wrapper.parents('body').delegate('#j_my_record', 'click', function() {
                var $this = $(this);
                window.location.href = $this.data('record') + '?token=' + self.token;
            });

            //抽奖按钮
            wrapper.delegate('#j-go', 'click', function() {
                var $this = $(this);
                // $.ajax({
                //     type: "get",
                //     url: self.url.getLottery,
                //     // data: JSON.stringify(self._getLotteryJson(node)),
                //     data: self._getLotteryJson($(this)),
                //     contentType: "application/json;charset=utf-8",
                //     dataType: "json",
                //     success: function(data){
                //         self._getLotterySucc($this,data);
                //     },
                //     error: function (data) {
                //         var res = JSON.parse(data.responseText);
                //         if(res.code == -300){
                //             $('.j_more').removeClass('hide');
                //         }else{
                //             alert(res.err);
                //         }
                //     }
                // });
                var demoObj = {
                    "id": 111,
                    "mId": 111,
                    "levelName": "奖品等级",
                    "itemName": "随便什么奖",
                    "needInfo":1, //是否需要填写用户信息 0不需要 1需要
                    "emptyactAward":0 //是否为空奖 0是1不是（谢谢参与）
                };
                var demoPrizeData = {
                    "actawardawardForWeb": demoObj,
                    "code": 200
                }


                self._getLotterySucc($this, demoPrizeData);
            });

            //实物奖品-立即领取
            wrapper.parents('body').delegate('.j_to_fill', 'click', function() {
                var $this = $(this);
                window.location.href = $this.data('fill') + '?token=' + self.token + '&mid=' + $this.data('mid') + '&pid=' + $this.data('pid');
            });

            //虚拟奖-查看详情
            wrapper.parents('body').delegate('.j_xuni', 'click', function() {
                var $this = $(this);
                console.log($(this).data('xuni'));
                window.location.href = $this.data('xuni');
                
                // $(self.opts.node).html('')

            });


            //提交用户领奖信息
            wrapper.delegate('#j_user_apply', 'click', function() {
                var $this = $(this);
                var node = $this.parents('.fill-info');
                var jsonUrl = self.url.userApply + '?token=' + self.token + '&actId=' + self.actId + '&platform=' + self.platform.pandaVideo + '&mId=' + self.mId;

                if (self._checkMust(node.find('input.must'))) {

                    $.ajax({
                        type: "post",
                        url: jsonUrl,
                        data: JSON.stringify(self._userApplyJson(node)),
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function(data, XMLHttpRequest, xhr) {
                            console.log(data);
                            console.log(xhr.status);
                            $('.j-apply-popup').removeClass('hide');
                        },
                        error: function(data) {
                            var res = JSON.parse(data.responseText);
                            alert(res.err);
                        }

                    });

                }
            });


        },

        /**
         * 验证登陆状态：1，无有效token；2，token无效 即无有效登录token则呼起app登陆
         * 检查cookie中是否已有userToken 有的话拼接到url中重载页面
         * 检查url中是否有token 有的话进行token验证
         * @private
         */
        _loginCheck: function() {
            var self = this,
                thisUrl = window.location.href,
                urlParaString = window.location.href.split("?")[1],
                paraArr = null,
                paraToken = null,
                loginJson = {};
            //读取cookie
            function getCookie(name) {
                var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
                if (arr = document.cookie.match(reg))
                    return unescape(arr[2]);
                else
                    return null;
            }
            if (thisUrl.indexOf('token') > -1) {

                if (typeof(urlParaString) != 'undefined') {
                    paraArr = urlParaString.split("&");
                    //url中取token
                    for (var i = 0, len = paraArr.length; i < len; i++) {
                        // document.write(cars[i] + "<br>");
                        if (typeof(paraArr[i].split("token=")[1]) != 'undefined') {
                            paraToken = paraArr[i].split("token=")[1];
                        }
                    }
                }

                loginJson.Token = paraToken;
                self.token = paraToken;
                loginUrl = self.url.login + '?token=' + self.token;
                if (self.mock) {
                    self._loginSucc(self.loginMock);
                } else {
                    $.ajax({
                        type: "post",
                        url: loginUrl,
                        data: JSON.stringify(loginJson),
                        contentType: "application/json;charset=utf-8",
                        dataType: "json",
                        success: function(data) {
                            if (data.code == 200) {
                                self._loginSucc(data);
                            } else {
                                alert(data.comment);
                                // $('#j-login').trigger('click');

                            }
                        },
                        error: function(data) {
                            var res = JSON.parse(data.responseText);
                            alert(res.comment);

                        }
                    });
                }

            } else {
                // if(getCookie('userToken')){
                //     window.location.href = thisUrl + '?token=' + getCookie('userToken');
                // }else {
                //     //未登录呼起app登录
                //     // console.log('未登录');
                //     $('#j-login').trigger('click');
                // }
                window.location.href = 'lottery-main.html';
            }


        },
        /**
         * 登陆成功后的逻辑
         * @private
         */
        _loginSucc: function(data) {
            var self = this;
            self.uId = data.rslt.phone;
            window.location.href = $('#j_check_login').data('checkto') + '?token=' + self.token;
        },
        /**
         * 查看今日可用次数
         * {
            "code": 200,
            "totalAvaiableCount": 10000,
            "dailyAvaiableCount": 10000
            }
         * @private
         */
        _getCountAjax: function() {
            var self = this;

            // $.ajax({
            //     type: "get",
            //     url: self.url.getCount,
            //     // data: JSON.stringify(self._getCountJson()),
            //     data: self._getCountJson(),
            //     contentType: "application/json;charset=utf-8",
            //     dataType: "json",
            //     success: function(data){
            //         console.log(data.dailyAvaiableCount);
            //         $('#j_my_count').html(data.dailyAvaiableCount)
            //     },
            //     error: function (data) {
            //         var res = JSON.parse(data.responseText);
            //         alert(res.err);
            //     }
            // });
            $('#j_my_count').html(12);
        },


        /**
         * token 用户手机号
         * actId  活动编号
         * platform 平台id
         * @returns {*}
         * @private
         */
        _getCountJson: function() {
            var self = this;
            var getCountJson = {};
            getCountJson.token = self.token;
            getCountJson.actId = self.actId;
            getCountJson.platform = self.platform.pandaVideo;

            return getCountJson
        },


        _getListForShow: function() {
            var self = this;
            var list = [{
                phone: '182****0020',
                itemName: '2000元电影卡'
            }, {
                phone: '182****0019',
                itemName: '1900元电影卡'
            }, {
                phone: '182****0018',
                itemName: '1800元电影卡'
            }, {
                phone: '182****0017',
                itemName: '1700元电影卡'
            }, {
                phone: '182****0016',
                itemName: '1600元电影卡'
            }, {
                phone: '182****0015',
                itemName: '1500元电影卡'
            }, {
                phone: '182****0014',
                itemName: '1400元电影卡'
            }, {
                phone: '182****0013',
                itemName: '1300元电影卡'
            }, {
                phone: '182****0012',
                itemName: '1200元电影卡'
            }, {
                phone: '182****0011',
                itemName: '1100元电影卡'
            }, {
                phone: '182****0010',
                itemName: '1000元电影卡'
            }, {
                phone: '182****0009',
                itemName: '900元电影卡'
            }, {
                phone: '182****0008',
                itemName: '800元电影卡'
            }, {
                phone: '182****0007',
                itemName: '700元电影卡'
            }, {
                phone: '182****0006',
                itemName: '600元电影卡'
            }, ]
            self._drawShowList(list);
            // $.ajax({
            //     type: "get",
            //     url: self.url.listForShow,
            //     // data: JSON.stringify(self._getCountJson()),
            //     data: self._getListForShowJson(),
            //     contentType: "application/json;charset=utf-8",
            //     dataType: "json",
            //     success: function(data){
            //         console.log(data.AllMemberPrizes);
            //         if(data.code == 200){
            //             self._drawShowList(data.AllMemberPrizes);
            //         }
            //     },
            //     error: function (data) {
            //         var res = JSON.parse(data.responseText);
            //         alert(res.err);
            //     }
            // });


        },
        /**
         * 获得氛围渲染滚动名单的json
         * @returns {{}}
         * @private
         */
        _getListForShowJson: function() {
            var self = this;
            var forShowJson = {};
            forShowJson.n = 20;
            forShowJson.actId = self.actId;
            forShowJson.platform = self.platform.pandaVideo;

            return forShowJson

        },
        _drawShowList: function(list) {
            var self = this;
            var tem = '';
            for (var i = 0, ilen = list.length; i < ilen; i++) {
                var thisItem = list[i];
                tem += '<p>恭喜<span> ' + thisItem.phone + ' </span> 获得 <span>' + thisItem.itemName + ' </span></p>'
            }
            $('#j_scroll_list').html(tem);


        },


        /**
         * 抽奖json
         * @param node
         * @returns {*}
         * @private
         * 入参：
         * token
         * actId 写死
         * platform
         * inviteCode
         */

        _getLotteryJson: function(node) {
            var self = this;
            var getLJson = {};
            var inviteCode = node.find('.convert-code').val();
            getLJson.token = self.token;
            getLJson.actId = self.actId;
            getLJson.platform = self.platform.pandaVideo;
            getLJson.inviteCode = inviteCode;
            return getLJson
        },
        /**
         * 抽奖出参处理
         * {"actawardawardForWeb": {
                    "id": 奖品id,
                    "mId": 操作记录id,
                    "levelName": "奖品等级",
                    "itemName": "奖品名称",
                    "needInfo": 1,是否需要填写用户信息 0不需要 1需要
                    "emptyactAward": 是否为空奖 0是1不是（谢谢参与）
                },
                "code": 200
            }
         * @param data
         * @private
         */
        _getLotterySucc: function(node, data) {
            var self = this;

            console.log(data.actawardawardForWeb);
            var prizeInfo = data.actawardawardForWeb;

            node.parents('.drp-content').addClass('active');
            if (prizeInfo.emptyactAward == 0) { //空奖
                setTimeout(self._setTimeOutBox0, 3000);
            } else {
                if (prizeInfo.needInfo == 0) {
                    //不需填写信息且不是空奖（虚拟奖）
                    $('.j-prize').find('.j_to_fill').removeClass('j_to_fill').addClass('j_xuni').html('查看详情');

                } else {
                    $('.j-prize').find('.j_xuni').removeClass('j_xuni').addClass('j_to_fill').html('立即领取');

                }
                $('.j-prize').find('#j_prize_name').html(prizeInfo.itemName);
                $('.j-prize').find('#j_prize_img').attr('src', prizeInfo.awardPic);
                $('.j-prize').find('.j_to_fill').data('mid', prizeInfo.mId);
                $('.j-prize').find('.j_to_fill').data('pid', prizeInfo.id);

                setTimeout(self._setTimeOutBox1, 3000);


            }







        },
        /**
         * 填写信息页的奖品图片
         * @private
         */
        _needImg: function() {
            var self = this;
            var thisImg = '';
            var thisName = '';

            for (var i = 0, len = self.mockJson.data.length; i < len; i++) {
                var prizeItem = self.mockJson.data[i];
                if (self.pId == prizeItem.prizeId) {
                    thisImg = prizeItem.prizeImg2;
                    thisName = prizeItem.prizeName;
                }
            }
            $('.j_prize_nimg').attr('src', thisImg);
            $('.j_prize_name').html(thisName);

        },
        _recordListImg: function() {
            var self = this;
            var rlen = $('.record-list').find('.record-item').length;
            for (var i = 0; i < rlen; i++) {
                var thisItem = $('.record-list').find('.record-item').eq(i);
                var thisId = thisItem.data('pid');
                var thisImg = '';
                thisItem.find('.j_prize_nimg').attr('src', thisImg);

                // for(var j=0,jlen =self.mockJson.data.length;j<jlen;j++ ){
                //     var prizeItem = self.mockJson.data[j];
                //     if(thisId == prizeItem.prizeId){
                //         thisImg = prizeItem.prizeImg;
                //         thisItem.find('.j_prize_nimg').attr('src',thisImg)
                //     }
                //
                // }
            }


        },

        /**
         * 抽奖弹窗0 没中奖
         * @private
         */
        _setTimeOutBox0: function() {
            var temNum = parseInt($('#j_my_count').text());
            var nowNum = 0;
            if (temNum > 0) {
                nowNum = temNum - 1;
                $('#j_my_count').html(nowNum);
            }

            $('.popup.j-sad').removeClass('hide');

            $('.drp-content').removeClass('active');

        },
        /**
         * 抽奖弹窗1 中奖了
         * @private
         */
        _setTimeOutBox1: function() {
            var temNum = parseInt($('#j_my_count').text());
            var nowNum = 0;
            if (temNum > 0) {
                nowNum = temNum - 1;
                $('#j_my_count').html(nowNum);
            }

            $('.popup.j-prize').removeClass('hide');

            $('.drp-content').removeClass('active');

        },

        /**
         * 用户提交信息json
         * @param node
         * @returns {{}}
         * @private
         */
        _userApplyJson: function(node) {
            var self = this;
            var userApplyJson = {};

            var username = node.find('input.username');
            var phone = node.find('input.phone');
            var address = node.find('input.address');
            var email = node.find('input.email');

            userApplyJson.userName = username.val();
            userApplyJson.phone = phone.val();
            userApplyJson.email = email.val();
            userApplyJson.address = address.val();

            console.log(userApplyJson);
            return userApplyJson;
        },

        /**
         * 必填项检查
         * @param node
         * @private
         */
        _checkMust: function(node) {
            var flag = true;
            $(node).each(function(i) {
                var checkTxt = $.trim($(node[i]).val());
                if (checkTxt == '') {
                    $(node[i]).addClass('error');
                    flag = false;
                    return false;
                } else {
                    $(node[i]).removeClass('error');
                    // 验证手机号
                    if($(node[i]).hasClass('phone')){
                        var reg =/^((13[0-9])|(14[5,7,9])|(15[^4])|(18[0-9])|(17[0,1,3,5,6,7,8]))[0-9]{8}$/;
                        if(!reg.test($(node[i]).val())){
                            alert("请输入正确的手机号码");
                            return flag = false;
                        }
                    }else{
                        flag = true;
                    }
                    
                }
            });
            return flag;
        },
        /**
         * 请求中奖记录
         * @private
         */
        _getMyRecord: function() {
            var self = this;

            // $.ajax({
            //     type: "get",
            //     url: self.url.myRecord,
            //     // data: JSON.stringify(self._getCountJson()),
            //     data: self._getCountJson(), //入参跟查询次数一致
            //     contentType: "application/json;charset=utf-8",
            //     dataType: "json",
            //     success: function(data) {
            //         console.log(data);
            //         if (data.code == 200) {
            //             self._creatRecordList(data.memberPrizes);
            //         }
            //         // $('#j_my_count').html(data.dailyAvaiableCount)
            //     },
            //     error: function(data) {
            //         var res = JSON.parse(data.responseText);
            //         alert(res.err);
            //     }
            // });
        },
        _creatRecordList: function(list) {
            var self = this;
            var temHtml = '';
            for (var i = 0, len = list.length; i < len; i++) {
                var thisItem = list[i];
                // console.log(thisItem.enrollTime);
                if (thisItem.signUp == 0 && thisItem.needInfo != 0) { //没填写且不是虚拟物品 则有"填写联系方式按钮"
                    temHtml += '<div class="record-item clear" data-pid="' + thisItem.awardId + '"> ' +
                        '<div class="img-area"> ' +
                        '<img class="j_prize_nimg" src="' + thisItem.awardPic + '"> ' +
                        '</div> ' +
                        '<div class="txt-area"> ' +
                        '<p class="name">' + thisItem.itemName + '</p> ' +
                        '<p class="date">' + thisItem.enrollTime + '</p> ' +
                        '<p class="to-fill"><a class="j_to_fill" data-fill="../fill_info" data-mid="' + thisItem.id + '" data-pid="' + thisItem.awardId + '">填写联系方式</a></p> ' +
                        '</div> ' +
                        '</div>';
                } else {
                    temHtml += '<div class="record-item clear" data-pid="' + thisItem.awardId + '"> ' +
                        '<div class="img-area"> ' +
                        '<img class="j_prize_nimg" src="' + thisItem.awardPic + '"> ' +
                        '</div> ' +
                        '<div class="txt-area"> ' +
                        '<p class="name">' + thisItem.itemName + '</p> ' +
                        '<p class="date">' + thisItem.enrollTime + '</p> ' +
                        '</div> ' +
                        '</div>';
                }

            }
            $('.record-list').append(temHtml);
            // self._recordListImg();


            //todo  2,正式环节url替换  4，json数据库由trs读取

        },







        /**
         * 重新加载
         */
        reload: function() {
            this._init();
        }
    });

    /**
     * 暴露全局变量
     */
    if (!w.txActivity) {
        w.txActivity = function() {
            $('.j_wrapper').each(function() {
                new txActivity({
                    node: this
                });

            });
        };
    }

    /**
     * banner入口
     */
    $(function() {
        w.txActivity();
    });

})(window, jQuery);